//
//  SeemeMainVC.m
//  SelfDriving
//
//  Created by apple on 16/1/20.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "SeemeMainVC.h"
#import "XLSwitchView.h"
#import "SeemeDataVC.h"
#import "SeemeDynamicVC.h"
#import "FriendDetailsMainVC.h"
#import "FriendVisitorVC.h"
@interface SeemeMainVC ()<XLSwitchViewDelegate>
@property (strong, nonatomic) XLSwitchView *switchViews;
@property (nonatomic, strong)LoginResponseModel *user;
@end

@implementation SeemeMainVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = NO;
    _switchViews = [[XLSwitchView alloc] initWithFrame:CGRectMake(0,44,SCRE_WIDTH,SCRE_HEIGHT-44)];
    _switchViews.backgroundColor = [UIColor clearColor];
    _switchViews.delegate = self;
    _switchViews.btnWidth = SCRE_WIDTH/2;
    //    _switchViews.btncolor = UIColorFromRGB(0x7EBDE9);
    //    _switchViews.inecolor = UIColorFromRGB(0x7EBDE9);
    _switchViews.btncolor = UIColorGreen;
    _switchViews.inecolor = UIColorGreen;
    [_switchViews createUserInterface];
    UIButton *btn1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 64, SCRE_WIDTH/2, 44)];
    [btn1 setTitle:@"资料" forState:UIControlStateNormal];
    [self.view addSubview:btn1];
    UIButton *btn2 = [[UIButton alloc]initWithFrame:CGRectMake(SCRE_WIDTH/2, 64, SCRE_WIDTH/2, 44)];
    [btn2 setTitle:@"动态" forState:UIControlStateNormal];
    [self.view addSubview:btn2];
    [self.view addSubview:_switchViews];
    //    LoginResponseModel * user = [AppDelegate shareDelegate].user;
    
    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(toVipAction:)
     name:@"toVipAction"
     object:nil];
    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(togerenAction:)
     name:@"togerenAction"
     object:nil];
}

//skhead
#pragma mark 个人详情
-(void)togerenAction:(NSNotification *)not{
    UIStoryboard *customerStoryboard = [UIStoryboard storyboardWithName:@"MS"
                                                                 bundle:[NSBundle mainBundle]];
    FriendDetailsMainVC *searchResultDetailController = [customerStoryboard instantiateViewControllerWithIdentifier:@"FriendDetailsMainVC"];
    searchResultDetailController.model = not.object;
    [self.navigationController pushViewController:searchResultDetailController animated:YES];
    
}

#pragma mark 会员
-(void)toVipAction:(NSNotification *)not{
    UIStoryboard *customerStoryboard = [UIStoryboard storyboardWithName:@"GR"
                                                                 bundle:[NSBundle mainBundle]];
    UIViewController *searchResultDetailController = [customerStoryboard instantiateViewControllerWithIdentifier:@"VipCenteVC"];
    [self.navigationController pushViewController:searchResultDetailController animated:YES];
    
}
-(NSInteger)numberOfItemsInSwitchView:(XLSwitchView *)switchView{
    return 2;
}
-(UIViewController *)switchView:(XLSwitchView *)switchView withViewOfItem:(NSInteger)index{
    
//    if ([self.user.ismember isEqualToString:@"1"]) {
        if (index == 0) {
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"GR" bundle:nil];
            SeemeDataVC *vc = [storyboard instantiateViewControllerWithIdentifier:@"SeemeDataVC"];
            vc.title = @"   资料   ";
            vc.switchView = self.switchViews;
            return vc;
        }else{
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"GR" bundle:nil];
            SeemeDynamicVC *vc = [storyboard instantiateViewControllerWithIdentifier:@"SeemeDynamicVC"];
            vc.title = @"   动态   ";
            vc.switchView = self.switchViews;
            return vc;
        }
    /*
    }else{
        
        if (index == 0) {
//            QMUICommonViewController * vc = [QMUICommonViewController new];
//            vc.title = @"   资料   ";
//            UIImageView *headImgV = ImageView.img(@"skhead");
//            headImgV.frame = XYWH((SCREEN_WIDTH - 100)/2,20,100,100);
//            [vc.view addSubview:headImgV];
//            QMUILabel * label = [[QMUILabel alloc]initWithFont:[UIFont systemFontOfSize:24] textColor:UIColorBlack];
//            label.numberOfLines = 0;
//            label.text = @"hi,嘿\n没有人看过你\n快去附近主动结识朋友";
//            label.textAlignment = NSTextAlignmentCenter;
//            label.frame = XYWH(0,CGRectGetMaxY(headImgV.frame) + 20,SCREEN_WIDTH,150);
//            [vc.view addSubview:label];
//            //灰色字体
//            QMUILabel * grayLabel = [[QMUILabel alloc]initWithFont:[UIFont systemFontOfSize:16] textColor:UIColorGrayLighten];
//            grayLabel.numberOfLines = 0;
//            grayLabel.text = @"谁看过我只记录会员期间的用户/n超过3天未登录，将不会出现在附近\n更新资料，加入群组，发布动态将让你更受欢迎";
//            grayLabel.textAlignment = NSTextAlignmentCenter;
//            grayLabel.frame = XYWH(0,CGRectGetMaxY(label.frame),SCREEN_WIDTH,150);
//            [vc.view addSubview:grayLabel];
//            
//            
//            QMUIButton * becomeVipBtn = [QMUIButton buttonWithType:UIButtonTypeSystem];
//            [becomeVipBtn setTitle:@"成为会员，立即开启访客信息" forState:UIControlStateNormal];
//            [becomeVipBtn setBackgroundColor:UIColorBlack];
//            [becomeVipBtn setTitleColor:UIColorWhite forState:UIControlStateNormal];
//            becomeVipBtn.frame = XYWH(0,SCREEN_HEIGHT - 60 - 108,SCREEN_WIDTH,60);
//            [vc.view addSubview:becomeVipBtn];
            SeemeDataVC *vc = [[SeemeDataVC alloc] init];
            vc.title = @"资料";
            return vc;
            
        }else{
//            QMUICommonViewController * vc = [QMUICommonViewController new];
//            vc.title = @"   动态   ";
//            UIImageView *headImgV = ImageView.img(@"skhead");
//            headImgV.frame = XYWH((SCREEN_WIDTH - 100)/2,20,100,100);
//            [vc.view addSubview:headImgV];
//            QMUILabel * label = [[QMUILabel alloc]initWithFont:[UIFont systemFontOfSize:24] textColor:UIColorBlack];
//            label.numberOfLines = 0;
//            
//            label.text = @"hi,嘿\n没有人阅读过你的动态";
//            label.textAlignment = NSTextAlignmentCenter;
//            label.frame = XYWH(0,CGRectGetMaxY(headImgV.frame) + 20,SCREEN_WIDTH,150);
//            [vc.view addSubview:label];
//            
//            QMUILabel * grayLabel = [[QMUILabel alloc]initWithFont:[UIFont systemFontOfSize:16] textColor:UIColorGrayLighten];
//            grayLabel.numberOfLines = 0;
//            grayLabel.text = @"阅读过动态的人只记录旗舰会员期间的用户";
//            grayLabel.textAlignment = NSTextAlignmentCenter;
//            grayLabel.frame = XYWH(0,CGRectGetMaxY(label.frame),SCREEN_WIDTH,150);
//            [vc.view addSubview:grayLabel];
//            
//            
//            QMUIButton * becomeVipBtn = [QMUIButton buttonWithType:UIButtonTypeSystem];
//            [becomeVipBtn setTitle:@"开通SVIP，查看阅读过动态的人" forState:UIControlStateNormal];
//            [becomeVipBtn setBackgroundColor:UIColorBlack];
//            [becomeVipBtn setTitleColor:UIColorWhite forState:UIControlStateNormal];
//            becomeVipBtn.frame = XYWH(0,SCREEN_HEIGHT - 60 - 108,SCREEN_WIDTH,60);
//            [vc.view addSubview:becomeVipBtn];
            FriendVisitorVC *vc = [FriendVisitorVC new];
            vc.title = @"动态";
            return vc;
        }
        
    }
     */
    
    
    
    
}
-(void)ScrollAction:(NSInteger)index{
    NSNumber *indexs =  [NSNumber numberWithInteger:index];
    [UserDefaults writeUserDefaultObjectValue:[NSString stringWithFormat:@"%@",indexs] withKey:@"index"];
    
    
}
- (IBAction)backActino:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(LoginResponseModel *)user{
    if (!_user) {
        _user = [AppDelegate shareDelegate].user;
    }
    return _user;
}
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */



@end
